package com.linux.huhx.thread3.queueLength_1;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author: huhx
 * @Date: 2017-10-31 上午 8:47
 */
public class Service {
    private ReentrantLock lock = new ReentrantLock();

    public ReentrantLock getLock() {
        return lock;
    }

    public void serviceMethod1() {
        try {
            lock.lock();
            System.out.println("ThreadName = " + Thread.currentThread().getName() + " enter method.");
            Thread.sleep(Integer.MAX_VALUE);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }
}
